<template>
    <div>
        <div>
            <el-form :inline="true" class="demo-form-inline">
                <!-- <el-form-item label="当日美元汇率">
                    <el-input v-model="huilv" placeholder="当日美元汇率"></el-input>
                    <span> (此为人民币对美元汇率 例如0.1482)
                    </span>
                </el-form-item> -->
                <el-form-item label="用户折扣">
                    <el-input v-model="user" placeholder="用户折扣"></el-input>
                </el-form-item>
                <el-form-item label="保险公司折扣 ">
                    <el-input v-model="company" placeholder="保险公司折扣"></el-input>
                </el-form-item>
            </el-form>
        </div>
        <el-table :data="list" border style="width: 100%" height="400">
    
            <el-table-column prop="REPORTINFORMATION_ID" label="报案号" width="200">
            </el-table-column>
    
            <el-table-column prop="REPORTINFORMATION_CAUSE" label="报案事由" width="300">
            </el-table-column>
            <el-table-column prop="PRODUCTNAME" label="产品名称" width="200">
            </el-table-column>
            <el-table-column prop="CUSTNAME" label="被保险人姓名" width="150">
            </el-table-column>
            <el-table-column label="操作" width="150">
                <template scope="scope">
                    <el-button type="text" size="media" @click="gocheck(scope.row.RIID,scope.row.RISTATE)">
                        <i class="el-icon-edit" v-if="scope.row.RISTATE=='计算完成'"> 折扣计算</i>
                        <i class="el-icon-edit" v-else> 查看结果</i>
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
    
        <div class="block">
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage1" :page-size="10" layout="total, prev, pager, next" :total="pagecount">
            </el-pagination>
        </div>
    </div>
</template>
<script>
export default {

    data() {
        return {
            loading: false,
            list: [],
            currentPage1: 1,
            pagecount: 0,
            REPORTINFORMATION_ID: "",
            REPORTINFORMATION_IDENTITY: "",
            REPORTINFORMATION_RELATION: "",
            REPORTINFORMATION_USERNAME: "",
            REPORTINFORMATION_TIME: "",
            REPORTINFORMATION_WAY: "",
            REPORTINFORMATION_TEL: "",
            REPORTINFORMATION_EMAIL: "",
            // huilv: "",
            user: "",
            company: ""

        }
    },
    methods: {
        handleSizeChange(val) {

        },
        handleCurrentChange(val) {
            this.currentPage = val;

            this.$http.get("Lipei?pagesize=10&type=医疗保险&style=计算完成" + "&page=" + val).then(response => {
                var data = response.body;
                if (data.code == 1) {
                    this.list = data.result;
                } else {
                    this.$notify.error({
                        title: '失败',
                        message: '数据获取失败'
                    });
                }
            }, response => {
                this.$notify.error({
                    title: '网络错误',
                    message: '网络错误'
                });
                this.loding = false;
            });
        },
        gocheck(id, type) {
            if (type == "计算完成") {
                this.loading = true;
                // if (this.huilv == "") {
                //     this.$notify.error({
                //         title: '请输入汇率',
                //         message: '请输入汇率'
                //     })
                //     this.loading = false;
                //     return;
                // }
                this.$http.get("Bill/Zhekou?id=" + id + "&user=" + this.user + "&company=" + this.company).then(response => {
                    var data = response.body;
                    if (data.code == 1) {
                        this.$notify.success({
                            title: '成功',
                            message: '计算成功'
                        });
                        this.getdata();
                        this.loading = false;
                    } else {
                        this.getdata();
                        this.$notify.error({
                            title: '失败',
                            message: data.msg
                        })
                        this.loding = false;
                    }
                }, response => {
                    this.$notify.error({
                        title: '网络错误',
                        message: '网络错误'
                    });
                    this.loding = false;
                });
                this.loading = false;

            } else {
                this.$router.push({
                    name: 'zhekoujisuanform',
                    query: {
                        id: id

                    }
                })
            }
        },
        getdata() {
            this.$http.get("Lipei?pagesize=10&page=1&type=医疗保险&style=计算完成").then(response => {
                var data = response.body;
                if (data.code == 1) {
                    this.list = data.result;
                    this.pagecount = data.pagecount;
                } else {
                    this.$notify.error({
                        title: '失败',
                        message: '数据获取失败'
                    });
                }
            }, response => {
                this.$notify.error({
                    title: '网络错误',
                    message: '网络错误'
                });
                this.loding = false;
            });
        }
    },
    activated() {
        this.getdata();
    }
}
</script>
<style>

</style>